﻿<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>后台管理</title>
    <link href="/Styles/demo.css" rel="stylesheet" type="text/css" />
    <link href="/Scripts/themes/icon.css" rel="stylesheet" type="text/css" />
    <link href="/Scripts/themes/gray/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../Scripts/themes/icon.css" rel="stylesheet" />
</head>
<body class="easyui-layout">
    <div class="header" region="north" height="75" showsplit="false" showheader="false" data-options="region:'north',border:false">
        <img alt="" src="/Images/logo.png" style="float: left; width: 43px; height: 36px; padding-top: 17px; padding-left: 5px; padding-right: 10px;" />
        <h1>
            后台管理
        </h1>
        <div style="position: absolute; top: 8px; right: 10px;">
            <span id="RealName" style="color: Red; padding-right: 30px;"></span>
            <span id="RoleName" style="color: Red; padding-right: 30px;"></span>
            <span id="LoginTime" style="color: Red; padding-right: 30px;"></span><a id="btnQuit" iconcls="icon-cancel" onclick="onCloseClick()">退出</a>
        </div>
    </div>
    <div region="west" border="true" split="true" title="菜单列表" style="width: 190px; padding: 0px;">
        <div id="intxt" class="easyui-accordion" fit="true" border="false">
        </div>
    </div>
    <div id="mainPanle" region="center" border="true" border="false">
        <div id="tabs" class="easyui-tabs" fit="true" border="false">
            <div title="首页">
                <div class="cs-home-remark">
                </div>
            </div>
        </div>
    </div>
    <div data-options="region:'south',border:false" style="height: 50px;">
        <div style="text-align: center; cursor: default; padding-top: 15px;">
            Copyright © 版权所有<span id="datetime" style="float: right; padding-right: 50px;"></span>
        </div>
    </div>
    <div id="mm" class="easyui-menu cs-tab-menu" style="display: none">
        <div id="mm-tabupdate">
            刷新
        </div>
        <div class="menu-sep">
        </div>
        <div id="mm-tabclose">
            关闭
        </div>
        <div id="mm-tabcloseother">
            关闭其他
        </div>
        <div id="mm-tabcloseall">
            关闭全部
        </div>
    </div>
    <script src="/Scripts/common.js" type="text/javascript"></script>
    <script src="/Scripts/jquery-1.8.3.min.js" type="text/javascript"></script>
    <script src="/Scripts/jquery.cookie.js" type="text/javascript"></script>
    <script src="/Scripts/forbidden.js" type="text/javascript"></script>
    <script src="/Scripts/core.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function ()
        {
            $.ajax({
                url: "Menus.aspx?method=GetMenuList",
                cache: false,
                async: false,
                success: function (text)
                {
                    var jobj = $.parseJSON(text);
                    checkLogin(jobj, document);
                    $("#intxt").html(jobj.message);
                }
            });
        });
    </script>
    <script src="/Scripts/jquery.easyui.min.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
        function addTab(title, url)
        {
            if ($('#tabs').tabs('exists', title))
            {
                $('#tabs').tabs('select', title); //选中并刷新
                var currTab = $('#tabs').tabs('getSelected');
                var url = $(currTab.panel('options').content).attr('src');
                if (url != undefined && currTab.panel('options').title != 'Home')
                {
                    $('#tabs').tabs('update', {
                        tab: currTab,
                        options: {
                            content: createFrame(url)
                        }
                    });
                }
            } else
            {
                var content = createFrame(url);
                $('#tabs').tabs('add', {
                    title: title,
                    content: content,
                    closable: true
                });
            }
            tabClose();
        }
        function createFrame(url)
        {
            url += url.indexOf("?") > -1 ? "&rnd=" : "?rnd=";
            url += Math.random();
            var s = '<iframe scrolling="auto" frameborder="0"  src="' + url + '" style="width:100%;height:100%;"></iframe>';
            return s;
        }
        function tabClose()
        {
            /*双击关闭TAB选项卡*/
            $(".tabs-inner").dblclick(function ()
            {
                var subtitle = $(this).children(".tabs-closable").text();
                $('#tabs').tabs('close', subtitle);
            });
            /*为选项卡绑定右键*/
            $(".tabs-inner").bind('contextmenu', function (e)
            {
                $('#mm').menu('show', {
                    left: e.pageX,
                    top: e.pageY
                });
                var subtitle = $(this).children(".tabs-closable").text();
                $('#mm').data("currtab", subtitle);
                $('#tabs').tabs('select', subtitle);
                return false;
            });
        }
        //绑定右键菜单事件
        function tabCloseEven()
        {
            //刷新
            $('#mm-tabupdate').click(function ()
            {
                var currTab = $('#tabs').tabs('getSelected');
                var url = $(currTab.panel('options').content).attr('src');
                if (url != undefined && currTab.panel('options').title != 'Home')
                {
                    $('#tabs').tabs('update', {
                        tab: currTab,
                        options: {
                            content: createFrame(url)
                        }
                    });
                }
            });
            //关闭当前
            $('#mm-tabclose').click(function ()
            {
                var currtabTitle = $('#mm').data("currtab");
                $('#tabs').tabs('close', currtabTitle);
            });
            //全部关闭
            $('#mm-tabcloseall').click(function ()
            {
                $('.tabs-inner span').each(function (i, n)
                {
                    var t = $(n).text();
                    if (t != 'Home')
                    {
                        $('#tabs').tabs('close', t);
                    }
                });
            });
            //关闭除当前之外的TAB
            $('#mm-tabcloseother').click(function ()
            {
                var prevall = $('.tabs-selected').prevAll();
                var nextall = $('.tabs-selected').nextAll();
                if (prevall.length > 0)
                {
                    prevall.each(function (i, n)
                    {
                        var t = $('a:eq(0) span', $(n)).text();
                        if (t != 'Home')
                        {
                            $('#tabs').tabs('close', t);
                        }
                    });
                }
                if (nextall.length > 0)
                {
                    nextall.each(function (i, n)
                    {
                        var t = $('a:eq(0) span', $(n)).text();
                        if (t != 'Home')
                        {
                            $('#tabs').tabs('close', t);
                        }
                    });
                }
                return false;
            });
            //关闭当前右侧的TAB
            $('#mm-tabcloseright').click(function ()
            {
                var nextall = $('.tabs-selected').nextAll();
                if (nextall.length == 0)
                {
                    //msgShow('系统提示','后边没有啦~~','error');
                    alert('后边没有啦~~');
                    return false;
                }
                nextall.each(function (i, n)
                {
                    var t = $('a:eq(0) span', $(n)).text();
                    $('#tabs').tabs('close', t);
                });
                return false;
            });
            //关闭当前左侧的TAB
            $('#mm-tabcloseleft').click(function ()
            {
                var prevall = $('.tabs-selected').prevAll();
                if (prevall.length == 0)
                {
                    alert('到头了，前边没有啦~~');
                    return false;
                }
                prevall.each(function (i, n)
                {
                    var t = $('a:eq(0) span', $(n)).text();
                    $('#tabs').tabs('close', t);
                });
                return false;
            });
            //退出
            $("#mm-exit").click(function ()
            {
                $('#mm').menu('hide');
            });
        }
        $(function ()
        {
            tabCloseEven();
            $('.cs-navi-tab').click(function ()
            {
                var $this = $(this);
                var href = $this.attr('src');
                var title = $this.text();
                addTab(title, href);
            });
        });
        $('#btnQuit').linkbutton({
            plain: true
        });
        setInterval("datetime.innerHTML=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay());", 1000);
        $("#RealName").text($.cookie("RealName"));
        $("#RoleName").text($.cookie("RoleName"));
        $("#LoginTime").text($.cookie("LoginTime"));
        function onCloseClick()
        {
            if (confirm("确定退出系统吗？"))
            {
                $.cookie("RealName", null, { path: '/', expires: 1 });
                $.cookie("RoleName", null, { path: '/', expires: 1 });
                $.cookie("LoginTime", null, { path: '/', expires: 1 });
                window.location.href = "/Login.html";
            }
        }
        function showMessage(msg, messageId)
        {
            $.messager.show({
                title: '新消息',
                height: 300,
                width: 350,
                msg: '收到新的消息' + msg + '..前往查看详细', //可以点击在当前页面打开详细窗口
                timeout: 15000,
                showType: 'slide'
            });
        }
    </script>
</body>
</html>
